<?php 
/*
 module:		简历投递记录
 create_time:	2024-03-13 10:15:00
 author:		
 contact:		
*/

namespace app\api\service;
use app\api\model\Personaljobsapply;
use think\facade\Log;
use think\exception\ValidateException;
use xhadmin\CommonService;

class PersonaljobsapplyService extends CommonService {





	/*
 	* @Description  添加
 	*/
	public static function add($data){
		try{
			$res = Personaljobsapply::create($data);
		}catch(ValidateException $e){
			throw new ValidateException ($e->getError());
		}catch(\Exception $e){
			abort(config('my.error_log_code'),$e->getMessage());
		}
		return $res->did;
	}

    /*start*/
    /*
     * @Description  列表数据
     */
    public static function indexList($where,$field,$orderby,$limit,$page){
        try{
            $res = Personaljobsapply::with("jobs")->where($where)->field($field)->order($orderby)->paginate(['list_rows'=>$limit,'page'=>$page])->toArray();
        }catch(\Exception $e){
            abort(config('my.error_log_code'),$e->getMessage());
        }
        if (!empty($res["data"])) {
            $list = $res["data"];
            foreach ($list as &$item) {
               if(!empty($item["jobs"])){
                   $item["jobs"]["refreshtime"] = timeAnalysis2($item["jobs"]["refreshtime"]);
                   if (empty($item["jobs"]["tag_cn"]) || $item["jobs"]["tag_cn"] == "请选择") {
                       $item["jobs"]["tag_cn"] = [];
                   } else {
                       $item["jobs"]["tag_cn"] = explode(",", $item["jobs"]["tag_cn"]);
                   }
               }else{
                   $item["jobs"]["jobs"]=[];
               }
            }
            $res["data"] = $list;
        }
        return ['list'=>$res['data'],'count'=>$res['total']];
    }
    /*end*/
}

